#!/bin/bash

# -- the basic sed command syntax --
# $ sed [options] {sed-commands} {input-file}

# sed read lines one-by-one from the {input-file} and executes the {sed-commands} on that 
# particular line.

# {sed-command} can be single either a single sed command or multiple sed sedcommand
# syntax of multi sed-command: 
# $ sed [options] {sed-commands} {input-file}
sed -n 'p' /etc/passwd # print all lines in given file

# syntax of multi sed-command in a file: 
# $ sed [options] -f {sed-command-file} {input-file}
sed -n -f ./sed-command.sed /etc/passwd

# syntax of multi sed-command in a line: 
# $ sed [options] -e {sed-command-1} -e {sed-command-2} {input-file}
sed -n -e '/^root/ p' -e '/^nobody/ p' /etc/passwd

# syntax of multi sed-command in multi lines:
# $ sed [options] '{
#   sed-command-1
#   sed-command-2
#   sed-command-3
#   ...
# }' {input-file}
sed -n '{
    /^root/ p
    /^nobody p
}' /etc/passwd

# NOTE: sed never modifies the original file, it always prints the output to stdout, 
# if you want to save the changes, you should redirect to output to a file. 
